/*
 * MasterApp.java
 * classes : com.ruint.master.MasterApp
 * @author ruint
 * V 1.0.0
 * Create at 2014-11-26 下午5:44:23
 */
package com.ruint.master.app;

import android.database.sqlite.SQLiteDatabase;

import com.ruint.core.app.BaseApplication;
import com.ruint.core.cache.db.DataBaseOpenHelper;
import com.ruint.core.cache.db.DataBaseOpenHelper.DataBaseOpenListener;
import com.ruint.master.api.HttpApi;
import com.ruint.master.bean.User;

/**
 * com.ruint.master.MasterApp
 * 
 * @author ruint <br/>
 *         create at 2014-11-26 下午5:44:23
 */
public class MasterApplication extends BaseApplication<HttpApi> {
	private static final String TAG = "MasterApp";
	public static final String DB_NAME = TAG;

	private static MasterApplication mApp;
	private User user;

	public static MasterApplication getApp() {
		return mApp;
	}

	private DataBaseOpenListener dataBaseOpenListener = new DataBaseOpenListener() {

		@Override
		public void onVersionUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		}

		@Override
		public String[] getIndexSql() {
			return null;
		}

		@Override
		public String[] getCreateSql() {
			String createSql[] = new String[] {
					"CREATE TABLE IF NOT EXISTS budget (budgetid integer primary key autoincrement, id INTEGER,name varchar(20),time INTEGER)",
					"CREATE TABLE IF NOT EXISTS area (areaid integer primary key autoincrement, id INTEGER,name varchar(20),time INTEGER)" };
			return createSql;
		}
	};

	public DataBaseOpenHelper dataBaseOpenHelper;

	@Override
	protected void onAppCreate() {
		mApp = this;
		dataBaseOpenHelper = new DataBaseOpenHelper(this, DB_NAME, 1,
				dataBaseOpenListener);
		initImageLoader(this);
	}

	@Override
	protected void onAppDestory() {
	}

	@Override
	public void onAppCancel() {
	}

	@Override
	protected void instanceApi() {
		mApi = new HttpApi();
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return this.user;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

}
